const app = getApp();
var inputValue = app.globalData.inputValue;
Page({
  data: {
    StatusBar: app.globalData.StatusBar,
    CustomBar: app.globalData.CustomBar,
    ColorList: app.globalData.ColorList,
    itemInfo: "",
    item: ""
  },
  onLoad: function () { 
    this.setData({
      inputValue : app.globalData.inputValue
    })
  var that = this;
  wx.request({
    url: 'https://api.tianapi.com/txapi/lajifenlei/index?key=1e521f52cf54491890ce6ab26593e679&word='+app.globalData.inputValue+'&mode=1', 
    success: function (res) {
      if(res.data.code == 200){
      that.setData({
        //content: res.data.newslist[0].content,
        item: res.data.newslist[0].name,
        //itemInfo: res.data.newslist[0].type,
      })
      if(res.data.newslist[0].type == 0){
        that.setData({itemInfo: "可回收垃圾"})
      }
      if(res.data.newslist[0].type == 1){
        that.setData({itemInfo: "有害垃圾"})
      }
      if(res.data.newslist[0].type == 2){
        that.setData({itemInfo: "湿垃圾"})
      }
      if(res.data.newslist[0].type == 3){
        that.setData({itemInfo: "干垃圾"})
      }
    }else{
        that.setData({
          content: res.data.msg
        }) 
    }
    },
    fail: function (err) {
      console.log(err)
    }
  })
  },

// 生命周期函数--监听页面显示
onShow: function () {
  this.setData({
    inputValue : app.globalData.inputValue
  })
},


  back: function(e) {
    wx.navigateBack({
      delta: 1
    });
  }

});

